// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   TreeNode.java

package com.vandagroup.common.treedic;

import java.util.ArrayList;

public class TreeNode
{

    private String systemID;
    private String parentID;
    private String caption;
    private ArrayList childNodes;
    private ArrayList TreeNodeAttribute;
    private int currentLevel;

    protected int getCurrentLevel()
    {
        return currentLevel;
    }

    private void setCurrentLevel(int currentLevel)
    {
        this.currentLevel = currentLevel;
    }

    protected TreeNode(String systemID, String parentID, String caption)
    {
        currentLevel = 1;
        this.systemID = systemID;
        this.parentID = parentID;
        this.caption = caption;
    }

    protected TreeNode[] getChildNodes()
    {
        if(childNodes == null)
        {
            return new TreeNode[0];
        } else
        {
            TreeNode treeNode[] = new TreeNode[childNodes.size()];
            childNodes.toArray(treeNode);
            return treeNode;
        }
    }

    protected void addChildNode(TreeNode treeNode)
    {
        treeNode.setCurrentLevel(getCurrentLevel() + 1);
        if(childNodes == null)
            childNodes = new ArrayList();
        childNodes.add(treeNode);
    }

    protected void addChildNode(TreeNode treeNode, int position)
    {
        childNodes.add(position, treeNode);
    }

    protected void removeChildNode(TreeNode treeNode)
    {
        childNodes.remove(treeNode);
    }

    protected void removeAllChilds()
    {
        childNodes.clear();
    }

    protected String getCaption()
    {
        return caption;
    }

    protected void setCaption(String caption)
    {
        this.caption = caption;
    }

    protected String getParentID()
    {
        return parentID;
    }

    protected void setParentID(String parentID)
    {
        this.parentID = parentID;
    }

    protected String getSystemID()
    {
        return systemID;
    }

    protected void setSystemID(String systemID)
    {
        this.systemID = systemID;
    }

    protected ArrayList getTreeNodeAttribute()
    {
        return TreeNodeAttribute;
    }

    protected void setTreeNodeAttribute(ArrayList treeNodeAttribute)
    {
        TreeNodeAttribute = treeNodeAttribute;
    }

    protected ArrayList getArrayTree(TreeNode node, ArrayList array, int currLevel, int fetchLevel)
    {
        TreeNode nodes[] = node.getChildNodes();
        for(int i = 0; i < nodes.length; i++)
        {
            TreeNode oneNode = nodes[i];
            String value[] = {
                oneNode.getSystemID(), oneNode.getParentID(), oneNode.getCaption()
            };
            array.add(value);
            if(currLevel + 1 <= fetchLevel)
                oneNode.getArrayTree(oneNode, array, currLevel + 1, fetchLevel);
        }

        return array;
    }
}
